# (1) 定义了一个菜单条目类
class Entry:
    def __init__(self):
        self.no = ''
        self.text = ''


class MenuManager:
    def __init__(self):
        # print('构造函数')
        # (2) 存储菜单数据
        e1 = Entry()
        e1.no = '1'
        e1.text = '增加学生信息'

        e2 = Entry()
        e2.no = '2'
        e2.text = '删除学生信息'

        e3 = Entry()
        e3.no = '3'
        e3.text = '修改学生信息'

        e4 = Entry()
        e4.no = '4'
        e4.text = '查询学生信息'

        e5 = Entry()
        e5.no = '5'
        e5.text = '查询所有学生'

        e6 = Entry()
        e6.no = '6'
        e6.text = '排序'

        e0 = Entry()
        e0.no = '0'
        e0.text = '退出'

        self.menu = []  # 为什么不把e0-e6做成成员变量？
        self.menu.append(e1)
        self.menu.append(e2)
        self.menu.append(e3)
        self.menu.append(e4)
        self.menu.append(e5)
        self.menu.append(e6)
        self.menu.append(e0)

    def print_menu(self):
        # (3) 打印菜单
        print('*****菜单开始*****')

        for item in self.menu:
            print(item.no, item.text)

        print('*****菜单结束*****')


class StudentInfoSystem:
    def __init__(self):
        pass

    def execute(self):
        print('系统正在运行...')

        menu = MenuManager()

        while True:
            menu.print_menu()
            n = input('请选择菜单：')
            if n == '0':
                break
            elif n == '1':
                # print('1')
                self.save()

            elif n == '2':
                # print('2')
                self.remove()
            elif n == '3':
                # print('3')
                self.update()
            elif n == '4':
                # print('4')
                self.find_by_name()

            elif n == '5':
                self.find_all()
                # print('5')

            elif n == '6':
                self.sort()
                # print('6')
            else:
                print('无效的选项！')

    # 处理选项1
    def save(self):
        print('增加')

    def remove(self):
        print('删除')

    def update(self):
        print('修改')

    def find_by_name(self):
        print('根据姓名查询')

    # 处理选项5
    def find_all(self):
        print('查询所有')

        #打印所有的学生信息
        s1 = ['张三', 18, '男']
        s2 = ['李四', 12, '女']

        students = []
        students.append(s1)
        students.append(s2)

        for item in students:
            print('姓名: ',item[0],
                  '年龄: ', item[1],
                  '性别: ',item[2])

    def sort(self):
        print('排序')


system = StudentInfoSystem()
system.execute()  # ctrl + b
